home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 50
/
Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso
/
Aminet
/
dev
/
basic
/
BlitzLstMay02.lha
/
BlitzLstMay02
/
attachments
/
mail_61
/
blits.ab2
Wrap
Text File
|
2002-06-09
|
2KB
|
92 lines
optimize 7;
;A little demo of moving things using the Blit command...
; the image.res must inlcude in compileroptions to use this functions
WBStartup
;create a 'ball' type variable
;
NEWTYPE.ball
x.q
y
xs
ys
End NEWTYPE
DEFTYPE.l
;dimension a 'List' of 'balls'
Dim List balls.ball(150)
!image_include
Statement image_blitblock{x.l,y.l,x2,y2,w,h}
SHARED imagedat(),imgtags()
USEPATH imagedat(image)
If w=0 Then w=ScreenWidth
If h=0 Then h=ScreenHeight
*scr._Screen = Peek.l(Addr Screen(Used Screen))
If *scr=0 Then error{"Tried to blit into a non-exisiting screen !"}:Statement Return
If Peek.l(Addr Window(Used Window))
BltBitMapRastPort_ *scr\_BitMap,x2,y2,RastPort(Used Window),x,y,w,h,$c0
Else
error {"Tried to blit into a non-existing window "}
End If
End Statement
!screen_ {0,"","ram:prefsfile",1}:If scr\id=0 Then End
Window 0,0,0,scr\width,scr\height,$800,"",0,1
succ=image_load {1,"amiga1000.jpg"}
succ=image_load {0,"ball.iff"}
!screen_ {1,"","ram:prefsfile",0}:If scr\id=0 Then End
;a second screen for doublebuffer
Window 1,0,0,scr\width,scr\height,$800,"",0,1 ;second window
!screen_ {2,"","ram:prefsfile",0}:If scr\id=0 Then End
;keep adding items to list until list full
;
Window 2,0,0,scr\width,scr\height,$800,"",0,1 ;window to store backgroundimage
image_blit{1,0,0}
While AddLast(balls())
;Delay_(1) ;for better rnd values on winuae
balls()\x=Rnd(scr\width)-10,Rnd(scr\height)-10,(Rnd-.5)*20,(Rnd-.5)*20
Wend
;while mouse button not hit..
;
While Joyb(0)=0
ShowScreen num
num+1
If num>1 Then num=0
Use Window num
;start at first item in list
;
ResetList balls()
;WCls
Use Screen 2 ;use the backgroundimage from screen 2
image_blitblock{0} ;blit whole backgroundimage
WLocate 220,290
If res<5 Then res=5
WJam 0
NPrint "fps ",50/(res LSR 2)," ",num
;wait for vertical blank
;
;Delay_(1)
;while more items to come...
;
While NextItem(balls())
balls()\x+balls()\xs
balls()\y+balls()\ys
;reverse direction if ball gets to edge of bitmap
;
If balls()\x<10 OR balls()\x>scr\width Then balls()\xs=-balls()\xs
If balls()\y<10 OR balls()\y>scr\height Then balls()\ys=-balls()\ys
image_blitmask {0,balls()\x,balls()\y,1} ;draw balls
Wend
count+1
If count=4 Then count=0:res=Timer:ResetTimer
Wend
End ;important allow autofree